package org.ytor.core.sysapi.role.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.ytor.core.sqlflow.PersistenceModel;
import org.ytor.core.sqlflow.anno.Table;
import org.ytor.core.sysapi.role.resp.SysRolePermissionResp;

import java.util.List;

/**
 * created by yangtong on 2025/4/8 14:09:51
 * <br/>
 * 角色-资源关系
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Table("sys_role_permission")
public class SysRolePermission extends PersistenceModel<SysRolePermission, String> {
    /**
     * 角色id
     */
    private String roleId;

    /**
     * 父资源id
     */
    private String pid;

    /**
     * 资源id
     */
    private String permissionId;

    /**
     * 资源名称
     */
    private String permissionName;

    /**
     * 资源code
     */
    private String permissionCode;

    /**
     * 资源类型，1-接口、2-页面、3-页面元素
     */
    private String permissionType;

    /**
     * 是否有子数据
     */
    private Boolean hasChildren;

    /**
     * 子数据
     */
    private List<SysRolePermission> children;

    @Override
    public SysRolePermissionResp toResp() {
        SysRolePermissionResp rolePermissionResp = new SysRolePermissionResp();
        rolePermissionResp.setId(this.permissionId);
        rolePermissionResp.setPid(this.pid);
        rolePermissionResp.setRoleId(this.roleId);
        rolePermissionResp.setPermissionId(this.permissionId);
        rolePermissionResp.setPermissionCode(this.permissionCode);
        rolePermissionResp.setPermissionName(this.permissionName);
        return rolePermissionResp;
    }

}
